package applet;
import java.util.ArrayList;

import processing.core.PApplet;
import processing.core.PImage;

public class CompareRegion extends GuiElement{
	
	public BarChart ageBar;
	public PieChart countryPie;
	public GenderPieChart sexGPie;
	public boolean visible;
	public PImage image;
	
	CompareRegion(int xp, int yp, int w, int h) {
		x = xp;
		y = yp;
		width = w;
		height = h;
		
		ArrayList<ChartElement> testPieElement = new ArrayList<ChartElement>();
		ChartElement[] testPEArray = new ChartElement[20];
		for(int i = 0; i< 20; i++) {
			testPEArray[i] = new ChartElement(100*(i+1),"Test "+i);
			testPieElement.add(testPEArray[i]);
		}
		ArrayList<ChartElement> testBarElement = new ArrayList<ChartElement>();
		ChartElement[] testBEArray = new ChartElement[10];
		for(int i = 0; i< 10; i++) {
			testBEArray[i] = new ChartElement(200*(i+1),i*10+"");
			testBarElement.add(testBEArray[i]);
		}
		
		ageBar = new BarChart(x+530,y+5,150,150,testBarElement);
		countryPie = new PieChart(x+375,y+5,150,testPieElement);
		sexGPie = new GenderPieChart(x+400,y+30,100,6600,21000-6600);
		image = GLOBAL.processing.loadImage(GLOBAL.baseDir + "noImage.jpg");
		visible = false;
	}

	public void draw() {
		GLOBAL.processing.stroke(96);
		GLOBAL.processing.noFill();
		GLOBAL.processing.rect(x, y, width, height);
		if(visible) {
			GLOBAL.processing.imageMode(PApplet.CORNER);
			GLOBAL.processing.image(image, x+20, y+5, image.width*150.0f/image.height, 150);
			if(!GLOBAL.showingCountry) {
				sexGPie.draw();
				ageBar.draw();
			} else {
				countryPie.draw();
			}
		}
	}
	
	
}
